<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>添加类型</title>
    <meta content="webkit" name="renderer">

    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">

    <link href="layui-v2.6.4/layui/css/modules/code.css" rel="stylesheet" type="text/css"/>
    <link href="/layui-v2.6.4/layui/css/layui.css" media="all" rel="stylesheet">
    <script charset="UTF-8" src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" onclick="toEchart()" lay-event="toEchart">图形显示</button>
        <button class="layui-btn layui-btn-sm" onclick="toReSignin()">添加一个委托类型</button>
    </div>
    <!--    <div class="layui-input-block">-->
    <!--        <select name="city" lay-verify="required">-->
    <!--            <option  th:each="ele,a:${list}" th:text="ele">北京</option>-->
    <!--        </select>-->
    <!--    </div>-->

</script>

<script>
    function toEchart() {
        location.assign("/toEntrustTypeEchart")
    }
</script>
<!--action="/addEntrustType"-->
<script>
    function toReSignin() {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            shadeClose: true,
            skin: 'yourclass',
            content: '<div>\n' +
                '\t\t\t    <span id="msgs">&nbsp;</span>' +
                '\t\t\t    <span id="msg"    >&nbsp;</span>' +
                '\t\t\t    <form class="layui-form"   action="/addEntrustType" method="post" >\n' +
                '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                '\t\t\t            <label class="layui-form-label">请输入一个类型</label>\n' +
                '\t\t\t            <div class="layui-input-block">\n' +
                '\t\t\t                <input class="layui-input" type="text" id="EntrustType" name="EntrustType" required lay-verify="required"\n' +
                '\t\t\t                       placeholder="请输入一个类型" autocomplete="off"  onblur="a1()">\n' +
                '\t\t\t            </div>\n' +
                '\t\t\t        </div>\n' +
                '\t\t\t        <div class="layui-form-item" style="margin: 20px;">\n' +
                '\t\t\t            <div class="layui-input-block">\n' +
                '\t\t\t                <input class="layui-btn"    value="验证">\n' +
                '\t\t\t                <input class="layui-btn" type="submit"    value="提交">\n' +
                '\t\t\t            </div>\n' +
                '\t\t\t        </div>\n' +
                '\t\t\t    </form>\n' +
                '\t\t\t</div>'
        });
    }
</script>

<script>
    function a1() {
        $.ajax({
            url: "/judgeTypeRep"
            , type: 'get'
            , async: false
            , data: {
                EntrustType: $("#EntrustType").val()
            }
            , success: function (data) {
                if (data.toString() == "ok") {
                    $("#msgs").css("color", "green")
                    layer.msg('无重复可插入');
                } else {
                    $("#msgs").css("color", "red")
                    layer.msg('!!!有重复!!不插入');
                }
                $("#msgs").html(data)
            }
        });
    }
</script>

<script id="barDemo" type="text/html">
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">查看相关数据</a>
</script>
<script charset="utf-8" src="/layui-v2.6.4/layui/layui.js"></script>

<script th:inline="javascript" type="text/javascript">
    layui.use('table', function () {
        var table = layui.table;
        table.render({
            elem: '#test',
            url: 'getAllEtrustType',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                }
            },
            page: true,
            limits: [3, 5, 10, 20],
            limit: 10,
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            height: 'full-3',
            defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            title: '管理员数据表',
            cols: [
                [{
                    type: 'checkbox',
                    fixed: 'left'
                }, {
                    field: 'enTypeId',
                    title: '类型id',
                    width: 100,
                    edit: 'text',
                    sort: true
                }, {
                    field: 'entType',
                    title: '委托类型',
                    width: 110,
                    edit: 'text',
                    sort: true
                }, {
                    fixed: 'right',
                    title: '操作',
                    toolbar: '#barDemo',
                    width: 150
                }]
            ]
        });

        //监听行工具事件
        //跳转到向管类型信息的详细数据
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                location.assign("toEntrustByType/" + data.enTypeId)
            }
        });
    });


</script>

</body>
</html>
